package com.liuhongwei.test.builder.strategy.impl;

import com.liuhongwei.test.bean.TableInfo;
import com.liuhongwei.test.builder.BuildExtendMapperXml;
import com.liuhongwei.test.builder.strategy.inf.MapperXmlStrategy;

import java.io.BufferedWriter;
import java.io.IOException;

/**
 * 生成查询数量
 */
public class XmlFieldSelectCountImpl implements MapperXmlStrategy {

    @Override
    public void generateMapperXml(TableInfo tableInfo, BufferedWriter bw) throws IOException {
        bw.write("\t<!--查询数量-->\n");
        bw.write("\t<select id=\"selectCount\" resultType=\"java.lang.Integer\">\n");
        bw.write("\t\tSELECT count(1)\n");
        bw.write("\t\tFROM " + tableInfo.getTableName() + "\n");
        bw.write("\t\t" + BuildExtendMapperXml.includeQueryCondition() + "\n");
        bw.write("\t</select>\n\n");
    }
}
